home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.02 Feb 93 / Screen I⁄O Classes / duMainPane.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-29  |  3.0 KB  |  126 lines  |  [TEXT/KAHL]

  1. /****
  2.  * duMainPane.c
  3.  *
  4.  *    Pane methods for a typical application.
  5.  *
  6.  *  Copyright © 1990 Symantec Corporation.  All rights reserved.
  7.  *
  8.  ****/
  9.  
  10. /**
  11.  *
  12.  *  Most applications will want a scrollable window, so this
  13.  *  class is based on the class CPanorama. All the methods here
  14.  *  would still apply to classes based directly on CPane.
  15.  *
  16.  **/
  17.  
  18. #include "duMainPane.h"
  19.  
  20.  
  21. void duMainPane::IduMainPane(CView *anEnclosure, CBureaucrat *aSupervisor,
  22.                             short aWidth, short aHeight,
  23.                             short aHEncl, short aVEncl,
  24.                             SizingOption aHSizing, SizingOption aVSizing)
  25. {
  26.     CPanorama::IPanorama(anEnclosure, aSupervisor, aWidth, aHeight,
  27.                             aHEncl, aVEncl, aHSizing, aVSizing);
  28. }
  29.  
  30. /***
  31.  * Draw
  32.  *
  33.  *    In this method, you draw whatever you need to display in
  34.  *    your pane. The area parameter gives the portion of the 
  35.  *    pane that needs to be redrawn. Area is in frame coordinates.
  36.  *
  37.  ***/
  38.  
  39. void duMainPane::Draw(Rect *area)
  40.  
  41. {
  42.     /* draw your stuff */
  43. }
  44.  
  45.  
  46. /***
  47.  * DoClick
  48.  *
  49.  *    The mouse went down in the pane.
  50.  *    In this method you do whatever is appropriate for your
  51.  *    application. HitPt is given in frame coordinates. The other
  52.  *    parameters, modiferKeys and when, are taken from the event
  53.  *    record.
  54.  *
  55.  *    If you want to implement mouse tracking, this is the method
  56.  *    to do it in. You need to create a subclass of CMouseTask and
  57.  *    pass it in a TrackMouse() message to the pane.
  58.  *
  59.  ***/ 
  60.  
  61. void duMainPane::DoClick(Point hitPt, short modifierKeys, long when)
  62.  
  63. {
  64.     /* what happens when the mouse goes down */
  65. }
  66.  
  67.  
  68. /***
  69.  * HitSamePart
  70.  *
  71.  *    Test whether pointA and pointB are in the same part.
  72.  *    "The same part" means different things for different applications.
  73.  *    In the default method, "the same part" means "in the same pane."
  74.  *    If you want a different behavior, override this method. For instance,
  75.  *    two points might be in the same part if they're within n pixels
  76.  *  of each other.
  77.  *
  78.  *    PointA and pointB are both in frame coordinates.
  79.  *
  80.  ***/
  81.  
  82. Boolean     duMainPane::HitSamePart(Point pointA, Point pointB)
  83.  
  84. {
  85.     return inherited::HitSamePart(pointA, pointB);
  86. }
  87.  
  88.  
  89. /***
  90.  * AdjustCursor
  91.  *
  92.  *    If you want the cursor to have a different shape in your pane,
  93.  *    do it in this method. If you want a different cursor for different
  94.  *    parts of the same pane, you'll need to change the mouseRgn like this:
  95.  *        1. Create a region for the "special area" of your pane.
  96.  *        2. Convert this region to global coordinates
  97.  *        3. Set the mouseRgn to the intersection of this region
  98.  *           and the original mouseRgn: SectRgn(mouseRgn, myRgn, mouseRgn);
  99.  *
  100.  *    The default method just sets the cursor to the arrow. If this is fine
  101.  *    for you, don't override this method.
  102.  *
  103.  ***/
  104.  
  105. void duMainPane::AdjustCursor(Point where, RgnHandle mouseRgn)
  106.  
  107. {
  108.     inherited::AdjustCursor(where, mouseRgn);
  109. }
  110.  
  111.  
  112. /***
  113.  * ScrollToSelection
  114.  *
  115.  *    If your pane is based on a Panorama (as this example is), you might
  116.  *    want to define what it means to have a selection and what it means to
  117.  *    scroll to that selection.
  118.  *
  119.  ***/
  120.  
  121. void duMainPane::ScrollToSelection(void)
  122.  
  123. {
  124.     /* scroll to the selection */
  125. }
  126.